var CN_COMMON_ARTICLE_ADD = function(){
	this.init();
};
CN_COMMON_ARTICLE_ADD.prototype.init = function(){
	var self = this;
	self.expand();
	
	self.initSomeThing();
	self.bandClick();
	self.bandResize();
}
/**
 * 拓展方法
 */
CN_COMMON_ARTICLE_ADD.prototype.expand = function(){
	var self = this;
	self.initSomeThing = function() {
		$("#articleCategory").select2();
		CN_WIDGET.initializeSelectVal('articleCategory');
		
		CN_WIDGET.triggerSelectOnCustom("articleLabel", {max:4,placeholder:'请添加文章标签'});
		CN_WIDGET.initializeSelectVal('articleLabel');
		
		$("#articleVisible").select2();
		CN_WIDGET.initializeSelectVal('articleVisible');
		
		$('#articleContent').summernote({
	        placeholder: '文章内容'
		});
	};
	self.bandClick = function() {
		
	};
	self.bandResize = function() {
	};
};
//供外部调用的方法
CN_COMMON_ARTICLE_ADD.prototype.submit = function(pType) {
	var articleAddFormIndex = submitHolder();
	if(!validInput("#articleTitle", ['requried'], "请填写文章标题！") || 
			!validInput("#articleCategory", ['requried'], "请选择文章分类！") || 
			!validInput("#articleLabel", ['requried'], "请添加文章标签！") || 
			!validInput("#articleVisible", ['requried'], "请选择他人是否可见！") || 
			!validInput("#articleContent", ['requried'], "请填写文章内容！")) {
		closeSubmitHolder(articleAddFormIndex);
		return;
	}
	$("#articleForm").attr("action", ctx + "front/article/" + pType + ".html");
	$("#articleForm").submit();
};
$(function() {
	window.cnCommonArticleAdd = new CN_COMMON_ARTICLE_ADD();
});